//package org.penguin.study.bk.config
//
//import org.springframework.beans.factory.annotation.Autowired
//import org.springframework.context.annotation.Bean
//import org.springframework.context.annotation.Configuration
//import org.springframework.core.env.Environment
//import org.springframework.core.env.get
//import org.springframework.data.jpa.repository.config.EnableJpaRepositories
//import org.springframework.jdbc.datasource.DriverManagerDataSource
//
//import org.springframework.transaction.annotation.EnableTransactionManagement
//import javax.sql.DataSource
//
//@Configuration
//@EnableJpaRepositories(basePackages = ["org.penguin.study.bk.dao"])
//@EnableTransactionManagement
//class JpaConfig {
//
////    @Autowired
////    lateinit var env: Environment
////
////    @Bean
////    fun dataSource(): DataSource {
////        return DriverManagerDataSource(
////            env["spring.datasource.url"]!!,
////            env["spring.datasource.username"]!!,
////            env["spring.datasource.password"]!!
////        )
////    }
//
//    @Bean
//    fun entityManagerFactory(dataSource: DataSource): LocalContainerEntityManagerFactoryBean {
//        val emf = LocalContainerEntityManagerFactoryBean()
//        emf.dataSource = dataSource
//        emf.setPackagesToScan("org.penguin.study.bk.entity")
//        emf.persistenceProvider = HibernatePersistenceProvider()
//        emf.setJpaProperties(jpaProperties())
//        return emf
//    }
//
//    private fun jpaProperties(): Properties {
//        val extraProperties = Properties()
//        extraProperties.put(ENV_HIBERNATE_FORMAT_SQL, true)
//        extraProperties.put(ENV_HIBERNATE_SHOW_SQL, true)
//        extraProperties.put(ENV_HIBERNATE_HBM2DDL_AUTO,"update")
//        extraProperties.put(ENV_HIBERNATE_DIALECT, "org.hibernate.dialect.MySQL5InnoDBDialect")
//        extraProperties.put("hibernate.physical_naming_strategy", CamelCaseToUnderscoresNamingStrategy::class.java.name)
//        extraProperties.put("hibernate.implicit_naming_strategy", SpringImplicitNamingStrategy::class.java.name)
//        return extraProperties
//    }
//
//    @Bean
//    fun transactionManager(entityManagerFactory: LocalContainerEntityManagerFactoryBean): PlatformTransactionManager {
//        return JpaTransactionManager(entityManagerFactory.getObject()!!)
//    }
//
//    companion object {
//        private const val ENV_HIBERNATE_DIALECT = "spring.jpa.database-platform"
//        private const val ENV_HIBERNATE_HBM2DDL_AUTO = "hibernate.hbm2ddl.auto"
//        private const val ENV_HIBERNATE_SHOW_SQL = "hibernate.show_sql"
//        private const val ENV_HIBERNATE_FORMAT_SQL = "hibernate.format_sql"
//    }
//}